2

Trying to run an example of a python arcade library game.

Paste the code to Pycharm: the line 'import arcade' fails because 'The Arcade Library requires Python 3.6 or higher.' . Try again with python3.7 interpreter, now it says 'No module named arcade' but Pycharm proposes to install the package. After input my sudo password, it says that the

'pip install arcade'

failed and to "make sure that you use the correct version of 'pip' installed for your Python interpreter located at '/usr/local/bin/python3.7'"

I open Terminal, try:

sudo pip3.7 install arcade

Installation fails because:

Could not fetch URL https://pypi.org/simple/arcade/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/arcade/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
Could not find a version that satisfies the requirement arcade (from versions: )
No matching distribution found for arcade
You are using pip version 10.0.1, however version 18.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

Lookup how to upgrade pip, find this thread, try every answer, none of them work because of the same reason: SSL module not available.

I also have to go back to the 3.4 interpreter in PyCharm because numpy cannot be used either. Am I stuck with my current version of python (3.4.3)? What do I have to do to install the latest modules?

OS is Linux Mint 17.3 In Terminal, default is 2.7.6 when typing 'python -V' and 3.4.3 when typing 'python3 -V', so need to specify 'python3.7'. Same goes with pip? (write pip3.7 instest of just pip or pip3?)

Alderven
  • 7,569
  • 5
  • 26
  • 38
Domiinic
  • 67
  • 1
  • 9

2 Answers2

1

it is recommended to use virtual environments when you have to satisfy different dependencies while working on different projects. You can use conda to get things done easily.

Type pip install conda to install conda. Conda can be used to set up new environments as well as installing packages. After installing conda create an environment as follows :

conda create --name nameofenv python=3.4

Change nameofenv to the name of the environment you want. Here I am creating an environment with python version 3.4. If you want to install the latest version of python, just remove the version numbers along with the equal to sign as follows :

conda create --name nameofenv python

The new environment will be created. You can activate this environment as follows in linux:

source activate nameofenv

After activating the environment you can use pip or conda to install the packages you want in to the new environment. The next time you open the terminal you need to activate the environment again to use it.

Now, you can select the environment for the project in Pycharm by going to File->Settings->ProjectName->Project interpreter. Click on the plus sign on the right side and now you have a window open to select the virtual environment. Click on the radiobutton that says existing environment and browse to select the environment under python folder in home folder if it is setup there. PythonFolder->envs->Folder with the same name as the environment that you have created earlier. Done.

arunken
  • 415
  • 3
  • 15
  • Installation of conda fails: Found existing installation: urllib3 1.7.1 Cannot uninstall 'urllib3'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. Other conda commands don't work as if it was never installed. – Domiinic Nov 26 '18 at 07:23
  • Do you have conda already installed? Check it by using "pip show conda" – arunken Nov 26 '18 at 07:28
  • Try to install miniconda or anaconda. You you are completely new to python I recommend anaconda because it comes with a GUI using which you can create environments easily. After you get used to python packages and commands, go with terminal install of packages and creating environments. Here is a nice tutorial from anaconda https://docs.anaconda.com/anaconda/navigator/tutorials/manage-environments/ – arunken Nov 26 '18 at 07:37
  • I followed [these steps][https://conda.io/docs/user-guide/install/linux.html] and installed both Miniconda and Anaconda. I successfully created a new environment in anaconda. In PyCharm, there is no radiobutton that says existing environment after I clicked on the first plus sign. I still found "3.7.1 (~/anaconda3/envs/nameofenv/bin/python)" as a Project Interpreter, I chose it and Applied the change. But now when I run 'import arcade' the command fails because "PackagesNotFoundError: The following packages are not available from current channels:" – Domiinic Nov 26 '18 at 07:58
  • Dude, Anaconda asked if I wanted to install some microsoft visual studio things and I accepted, but after 2 minutes I had to Abort the installation with Ctrl + C because it was doing weird stuff. Then I noticed things like printscreens fail and folder navigator didn't look the same. So I rebooted my computer. Now Cinnamon doesn't load when I restart and everything look black. I'm currently using safemode to open my browser but options are limited. I'm panicking ! This installation destroyed my Linux Laptop ! I need it for everything ! – Domiinic Nov 26 '18 at 08:18
  • It shouldn't mess up your linux installation. You must have opted for Visual Studio Code installation just after anaconda got completely installed. it wasn't necessary. But regardless during the installation you shouldn't have aborted as there might be some updation of linux packages. Please calm down. there will be a fix of some sort. But you need to find the reason behind the problem you're facing. Can you try to install VS code again? – arunken Nov 26 '18 at 19:32
  • You shouldn't make any changes to the core python that comes with cinnamon(python 2.7) as it is used for many of the UI elements and plugins. – arunken Nov 26 '18 at 19:35
  • Before I do anything else I am backing up my hard drive. Might take 2-3 days. Meanwhile how do I input terminal commands in recovery? Still looking for it. I want to reinstall VS. If it doesn't fix I'll follow these steps https://forums.linuxmint.com/viewtopic.php?t=243566 . I posted my new problem here: https://forums.linuxmint.com/viewtopic.php?f=46&t=282265 – Domiinic Nov 26 '18 at 22:54
  • This could probably help you to automatically boot to GUI. https://community.linuxmint.com/tutorial/view/460 – arunken Nov 27 '18 at 09:01
  • 1
    Hey. Just let you know I backedup my hard drive and reinstalled my OS from a USB boot. It took weeks to setup everything close to the way it was before. Luckyily I didn't lose anything. Regarding Conda, is it necessary to use a virtual environment? All I want to do is use the arcade module. I am using pycharm community edition. – Domiinic Dec 30 '18 at 12:26
  • When you are working on multiple projects you will be needing different environments for each depending on the requirements. It is like creating folders and organizing files. In the same folder you cannot have files with the same name. Similarly, you will be needing different environments to have the same modules but different versions. It depends on the dependencies of your project. Once you have different environments, you can delete the one that is not needed anymore. – arunken Dec 30 '18 at 18:51
  • But when you only have a single one, you cannot do that and they only way to maintain them is to remove the packages individually that are not needed. These are some of the benefits. As of now you can do away with virtual environments, but sooner you will find it to be the best and the only practice that you cannot do away with if you want to be a python developer. – arunken Dec 30 '18 at 18:51
  • So now I am using anaconda3 to manage my projects. The python version I am using for my current project is 3.6 so it should be able to install the arcade module. I typed 'sudo pip3 install arcade' in Terminal and it successfully installed. But then what's next? I don't see any arcade package in anaconda gui. And typing 'import arcade' in Pycharm still points out that there's 'no module named arcade'. How can I make sure the virtual environment I am running my project in is able to install the modules that I already installed in the terminal? (btw 'python3 -V' returns 'Python 3.7.1') – Domiinic Jan 02 '19 at 10:59
1

You can make sure you're loading the correct pip by calling it through the target python executable like this:

python3.7 -m pip install arcade

If the error persists you can try to download the binaries and configure, make, make altinstall (you can find a guide here). The key is not to try and install python through the package manager, since the repo for 14.04, 16.04, 17.03 are not pointing to the latest 3.x version of python.

When you have working versions of the python 3.x you can create virtual environments in PyCharm (as Arun Otaku suggested).

Borisu
  • 828
  • 7
  • 15
  • I'm currently backing up my laptop hard drive from recovery mode because aborting visual studio installation crashed cinnamon UI. I'll try your recommendation as soon as I can. – Domiinic Nov 27 '18 at 04:33